home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Mania 4
/
MacMania 4.toast
/
/
Internet software
/
Drag-n-Drop-Email-as.02
/
Drag n Drop Email (text)
< prev
next >
Wrap
Text File
|
1996-06-02
|
3KB
|
122 lines
global LF, CR, CRLF
property isitSet : false
property emailHost : ""
property returnAddress : ""
property userName : ""
on run
set defaultReturnaddress to {"me@wherever.com"}
set dialogResponse to (display dialog "Enter your complete e-mail address: " default answer defaultReturnaddress)
if (button returned of dialogResponse ≠ "OK") then
return
else
set returnAddress to text returned of dialogResponse
if returnAddress = defaultReturnaddress then
return
end if
end if
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"@"}
set userName to first text item of returnAddress
set emailHost to "mail." & last text item of returnAddress
set AppleScript's text item delimiters to oldDelimiters
set isitSet to true
end run
on open (docList)
if not isitSet then
run
end if
set closeAfter to false
if not (PPPopened) then
set closeAfter to true
openPPP (getPPPServer)
repeat while not (PPPopened)
end repeat
end if
set LF to ASCII character (10)
set CR to return
set CRLF to CR & LF
set sss to (tcp connect to host emailHost port 25)
try
readresponse(sss)
repeat with aFile in docList
set aFile to contents of aFile
tcp write data "mail from: " & returnAddress & return ¬
stream sss using ISO88591
readresponse(sss)
set afilename to aFile as string
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set theFileName to last text item of afilename
set AppleScript's text item delimiters to oldDelimiters
set emailSubject to theFileName as text
open for access afilename
set sendToaddress to (read afilename before return)
set mailContents to (read afilename)
close access afilename
tcp write data "rcpt to: " & sendToaddress & return ¬
stream sss using ISO88591
readresponse(sss)
tcp write data "data" & return stream sss using ISO88591
readresponse(sss)
tcp write data "To: " & sendToaddress & return stream sss using ISO88591
tcp write data "Subject: " & emailSubject & return stream sss using ISO88591
tcp write data mailContents & return stream sss using ISO88591
tcp write data "." & return stream sss using ISO88591
readresponse(sss)
end repeat
tcp close stream sss
if closeAfter = true then
if (PPPopened) = true then
closePPP with hard close
end if
end if
return
on error msg number num
tcp close stream sss
display dialog "Error: " & msg & " " & num
end try
end open
on readresponse(sstream)
set LF to ASCII character (10)
set continuechar to "-"
set wholemessage to ""
repeat until continuechar = " "
repeat until (tcp ahead characters LF stream sstream)
end repeat
set readline to (tcp read until characters LF stream sstream using ISO88591)
set scan to (scanline(readline))
set continuechar to item 2 of scan
set wholemessage to wholemessage & " " & item 3 of scan
end repeat
set errorCode to item 1 of scan as integer
if (errorCode ≥ 400) then
display dialog "Error: " & wholemessage
error wholemessage number errorCode
end if
end readresponse
on scanline(lline)
return {characters 1 through 3 of lline as string, character 4 of lline as string, ¬
characters 5 through end of lline as string}
end scanline